package com.ss.android.newmedia;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.ColorMatrixColorFilter;
import android.os.Message;
import android.webkit.CookieManager;
import android.webkit.WebView;

import com.bytedance.common.plugin.interfaces.pushmanager.PushSettingManager;
import com.bytedance.common.utility.Logger;
import com.bytedance.common.utility.c.SharedPreferenceCompat;
import com.bytedance.common.utility.collection.WeakList;
import com.bytedance.frameworks.b.a.ComponentsManifest;
import com.ss.android.account.Spipe;
import com.ss.android.account.b.OnAccountRefreshListener;
import com.ss.android.account.b.UserListManager;
import com.ss.android.account.model.SharePlatform;
import com.ss.android.account.model.SpipeCore;
import com.ss.android.action.b.ImpressionHelper;
import com.ss.android.b.AdManager;
import com.ss.android.common.AppContext;
import com.ss.android.common.callback.CallbackCenter;
import com.ss.android.common.app.AppHooks;
import com.ss.android.common.applog.AppLog;
import com.ss.android.common.util.NetworkUtils;
import com.ss.android.common.util.TtProperties;
import com.ss.android.d.SSDBHelper;
import com.ss.android.image.BaseImageManager;
import com.ss.android.newmedia.activity.AbsSplashActivity;
import com.ss.android.newmedia.activity.browser.BrowserActivity;
import com.ss.android.newmedia.e.AlertManager;
import com.ss.android.newmedia.e.JsObject;
import com.ss.android.newmedia.util.AppUtil;
import com.ss.android.update.SSUpdateChecker;
import com.ss.android.update.UpdateChecker;
import com.ss.android.update.UpdateHelper;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.lang.ref.WeakReference;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;

public abstract class BaseAppData extends MediaAppData implements OnAccountRefreshListener, AppHooks.AppBackgroundHook, AppLog.g, UpdateHelper.c {
    public interface a {
        void a(long arg1);
    }

    static final class CacheSizeThread extends Thread {
        private final BaseAppData mBaseAppData;
        private BaseImageManager mBaseImageManager;

        public CacheSizeThread(BaseAppData arg2, BaseImageManager arg3) {
            super("CacheSizeThread");
            this.mBaseAppData = arg2;
            this.mBaseImageManager = arg3;
        }

        public final void run() {
            long v0 = System.currentTimeMillis();
            long v2 = this.mBaseImageManager.d();
            Logger.d("BaseAppData", "calculate cache size time: " + (System.currentTimeMillis() - v0));
            a(this.mBaseAppData);
            b(this.mBaseAppData).set(v2);
            ce.set(0);
            this.mBaseAppData.mWeakHandler.post(c(this.mBaseAppData));
        }
    }

    private boolean a = false;
    private volatile long sessionId;
    public static final CallbackCenter.TYPE callbackTypeFeedArticleUmeng = new CallbackCenter.TYPE("TYPE_FEED_ARTICLE_UMENG");
    public static final CallbackCenter.TYPE callbackTypeGetRefreshButtonSetting = new CallbackCenter.TYPE("TYPE_GET_REFRESH_BUTTON_SETTING");
    public static final CallbackCenter.TYPE callbackTypeCityChangeClient = new CallbackCenter.TYPE("TYPE_CITY_CHANGE_CLIENT");
    public static final CallbackCenter.TYPE callbackTypeCommentExtraInfoChanged = new CallbackCenter.TYPE("TYPE_COMMENT_EXTRA_INFO_CHANGED");
    public static final CallbackCenter.TYPE callbackTypeSubscribePGCAddOrDelete = new CallbackCenter.TYPE("TYPE_SUBSCRIBE_PGC_ADD_OR_DELTE");
    public static final CallbackCenter.TYPE callbackTypeAccountRefresh = new CallbackCenter.TYPE("TYPE_ACCOUNT_REFRESH");
    public static final CallbackCenter.TYPE callbackTypeAddArticleCommentFromUpdate = new CallbackCenter.TYPE("TYPE_ADD_ARTICLE_COMMENT_FROM_UPDATE");
    public static final CallbackCenter.TYPE callbackTypeNotifyAppEnterBackground = new CallbackCenter.TYPE("TYPE_NOTIFY_APP_ENTER_BACKGROUND");
    public static final CallbackCenter.TYPE callbackTypeShareMiniVideo = new CallbackCenter.TYPE("TYPE_SHARE_MINI_VIDEO");
    public static final CallbackCenter.TYPE callbackTypeU11UpdateDetailDeleted = new CallbackCenter.TYPE("TYPE_U11_UPATE_DETAIL_DELETED");
    public static final CallbackCenter.TYPE callbackTypeSpipeItemStateChanged = new dd("TYPE_SPIPE_ITEM_STATE_CHANGED");
    public static final CallbackCenter.TYPE callbackTypeEnablePostStateChanged = new CallbackCenter.TYPE("TYPE_ENABLE_POST_STATE_CHANGED");
    public static final CallbackCenter.TYPE callbackTypeUserStateChanged = new ee("TYPE_USER_STATE_CHANGED");
    public static final CallbackCenter.TYPE callbackTypeRefreshGuideTopShow = new CallbackCenter.TYPE("TYPE_REFRESH_GUIDE_TOP_SHOW");
    public static final CallbackCenter.TYPE callbackTypePopUiShowStateChanged = new CallbackCenter.TYPE("__TYPE_POP_UI_SHOW_STATE_CHANGED__");
    public static final CallbackCenter.TYPE callbackTypeDeleteAnswer = new CallbackCenter.TYPE("TYPE_DELETE_ANSWER");
    public static final CallbackCenter.TYPE callbackTypeFontSizeChange = new CallbackCenter.TYPE("TYPE_FONT_SIZE_CHANGE");
    public static final CallbackCenter.TYPE callbackTypeDiggBuryChange = new CallbackCenter.TYPE("TYPE_DIGG_BURY_CHANGE");
    public static final CallbackCenter.TYPE callbackTypeArticleSubOrUnsub = new CallbackCenter.TYPE("TYPE_ARTICLE_SUB_OR_UNSUB");
    public static final CallbackCenter.TYPE callbackTypeVideoSubOrUnsub = new CallbackCenter.TYPE("TYPE_VIDEO_SUB_OR_UNSUB");
    public String bV = "";
    public long bW = 0;
    public long bX = 0;
    public List bY;
    public List bZ;
    private String c;
    public List ca;
    public int cb = -1;
    public String cc;
    public final AlertManager mAlertManager;
    public static final AtomicLong ce = new AtomicLong();
    final Object cf = new Object();
    int cg = 0;
    int ch = 0;
    WeakReference ci;
    public boolean cj = false;
    public int ck = 0;
    public final WeakList cl = new WeakList();
    public UserListManager cm;
    public boolean userAllowUseMobileNet = false;
    public final WeakList co = new WeakList();
    public int cp = 0;
    public int cq = 0;
    public int cr = 0;
    public int cs = 0;
    public String ct;
    public String cu;
    public String cv;
    public int cw = -1;
    public int cx = 0;
    public int cy = 0;
    public boolean mConcernDialogShown = true;
    private final AtomicLong d = new AtomicLong(0);
    private boolean e = false;
    private final Runnable f = new ff(this);
    private static int mConfirmPush = -1;
    private static int h = -1;
    private String i;

    static {
        new CallbackCenter.TYPE("TYPE_SUBSCRIBE_PGC_UPDATE");
        new ColorMatrixColorFilter(new float[]{0.5f, 0f, 0f, 0f, 0f, 0f, 0.5f, 0f, 0f, 0f, 0f, 0f, 0.5f, 0f, 0f, 0f, 0f, 0f, 1f, 0f});
    }

    public BaseAppData(AppContext appContext, String arg7, String arg8) {
        super(appContext);
        new WeakList();
        new WeakList();
        this.c = arg7;
        this.cc = arg8;
        try {
            new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
        } catch (Exception e) {
        }

        this.mAlertManager = new AlertManager(this.mContext, this);
    }

    public void H() {
    }

    public boolean useOldParseJsonStyle() {
        return false;
    }

    public int useImageQqShare() {
        return 0;
    }

    private static String a(boolean[] arg3, JSONObject arg4, String arg5, String arg6) {
        arg3[0] = false;
        String v0 = null;
        try {
            JSONArray v1_1 = arg4.optJSONArray(arg5);
            if (v1_1 == null) {
//                goto label_6;
            } else {
                v0 = v1_1.toString();
            }
        } catch (Exception v1) {
        }

//        label_6:
        if (!android.support.design.a.isTextEquals(v0, arg6)) {
            arg3[0] = true;
        } else {
            v0 = arg6;
        }

        return v0;
    }

    public static synchronized void a(Context arg6, boolean arg7) {
        PushSettingManager v2_2;
        boolean isAllowNetwork = true;
        int v2 = arg7 ? 1 : 0;
        if (mConfirmPush == v2) {
            return;
        }
        mConfirmPush = v2;
        SharedPreferences.Editor v2_1 = arg6.getSharedPreferences("app_setting", 0).edit();
        v2_1.putInt("confirm_push", mConfirmPush);
        SharedPreferenceCompat.commit(v2_1);
        v2_2 = PushSettingManager.getInstance();
        if (mConfirmPush <= 0) {
            isAllowNetwork = false;
        }
        v2_2.notifyAllowNetwork(arg6, isAllowNetwork);
    }

    public static void a(String arg7, List arg8) {
        int v0_2;
        com.ss.android.newmedia.activity.a.a v5;
        int v2;
        if (!android.support.design.a.isTextEmpty(arg7)) {
            try {
                JSONArray v3 = new JSONArray(arg7);
                int v4 = v3.length();
                v2 = 0;
                while (true) {
                    label_8:
                    if (v2 >= v4) {
                        return;
                    }

                    JSONObject v0_1 = v3.getJSONObject(v2);
                    v5 = new com.ss.android.newmedia.activity.a.a();
                    v5.a = v0_1.getInt("type");
                    v5.b = v0_1.getString("text");
                    if (android.support.design.a.isTextEmpty(v5.b)) {
                        break;
                    } else if (v5.a >= 0) {
                        v0_2 = 1;
                    } else {
                        v0_2 = 0;
                    }

                    try {
                        label_24:
                        if (v0_2 != 0) {
                            arg8.add(v5);
                        }
                    } catch (Exception v0) {
                        return;
                    }

                    ++v2;
                    continue;
                }
            } catch (Exception v0) {
                return;
            }


        }
    }

    static boolean a(BaseAppData arg1) {
        arg1.cj = true;
        return true;
    }

    public final int a(BaseImageManager arg5) {
        int v0 = 0;
        if (arg5 != null) {
            Logger.d("BaseAppData", "requestCalcCacheSize " + this.cg);
            Object v1 = this.cf;
            synchronized (v1) {
                if (this.cg > this.ch) {
                    v0 = 1;
                }

                ++this.cg;
                this.ci = new WeakReference(arg5);
                if (v0 == 0) {
                    this.ch = this.cg;
                    new CacheSizeThread(this, arg5).start();
                }

                v0 = this.cg;
                return v0;
            }
        }

        return v0;
    }

    public Intent a(Context arg2, int arg3, int arg4, JSONObject arg5, boolean arg6) {
        return null;
    }

    public String a(Context context, WebView webView) {
        String v0 = AppUtil.getUserAgent(context, webView);
        if (v0 == null) {
            v0 = "";
        }

        if (!android.support.design.a.isTextEmpty(v0)) {
            v0 = v0 + " JsSdk/2";
        }

        return v0;
    }

    public final void a(long arg12, String arg14, JSONObject arg15) {
        int v1_1;
        Object v0_5;
        ArrayList v0_4 = null;
        List v0_3;
        ImpressionHelper v2 = ImpressionHelper.getInstance();
        SSDBHelper v1 = this.getDBHelper();
        if (arg15 != null && v1 != null) {
            JSONArray v3 = new JSONArray();
            long v4 = System.currentTimeMillis();
            AtomicInteger v6 = v2.d;
            synchronized (v6) {
                if (v2.d.compareAndSet(0, 1)) {
                    Message v0_1 = v2.e.obtainMessage(100);
                    v0_1.obj = Long.valueOf(arg12);
                    v2.e.sendMessage(v0_1);
                }

                try {
                    v2.d.wait(8000);
                } catch (Exception v0_2) {
                }

                v0_3 = v2.b;
                v2.b = null;
            }

            long v6_1 = System.currentTimeMillis();
            if (Logger.debug()) {
                Logger.d("ImpressionHelper", "wait for pack impression take " + (v6_1 - v4) + " ms");
            }

            if (v0_3 != null && !v0_3.isEmpty()) {
                v1.updateImpressionData(v0_3, false);
            }

            if (v0_3 == null) {
                v0_4 = new ArrayList();
            }

            v1.a(arg12, v0_4);
            if (v0_4 != null && !((List) v0_4).isEmpty()) {
                Iterator v4_1 = ((List) v0_4).iterator();
                while (true) {
                    label_55:
                    if (!v4_1.hasNext()) {
                        Logger.d("ImpressionHelper", "batchImpression: " + v3.toString());
                        break;
                    }

                    v0_5 = v4_1.next();
                    if (android.support.design.a.isTextEmpty(((com.ss.android.model.b) v0_5).keyName)) {
                        v1_1 = 0;
                    } else if (((com.ss.android.model.b) v0_5).jsonArray == null) {
                        v1_1 = 0;
                    } else if (((com.ss.android.model.b) v0_5).jsonArray.length() > 0) {
                        v1_1 = 1;
                    } else {
                        v1_1 = 0;
                    }

                    try {
                        label_67:
                        if (v1_1 == 0) {
                            continue;
                        }
                        JSONObject v1_2 = new JSONObject();
                        if (v2.f != null) {
                            ImpressionHelper.e$b.a(v1_2, "key_name", ((com.ss.android.model.b) v0_5).keyName);
                            ImpressionHelper.e$b.a(v1_2, "list_type", Integer.valueOf(((com.ss.android.model.b) v0_5).listType));
                            ImpressionHelper.e$b.a(v1_2, "impression", ((com.ss.android.model.b) v0_5).jsonArray);
                            if (!android.support.design.a.isTextEmpty(((com.ss.android.model.b) v0_5).extra)) {
                                ImpressionHelper.e$b.a(v1_2, "extra", new JSONObject(((com.ss.android.model.b) v0_5).extra));
                            }

                            if (android.support.design.a.isTextEmpty(arg14)) {
//                            goto label_94;
                            } else {
                                ImpressionHelper.e$b.a(v1_2, "session_id", arg14);
                            }
                        } else {
                            v1_2.put("key_name", ((com.ss.android.model.b) v0_5).keyName);
                            v1_2.put("list_type", ((com.ss.android.model.b) v0_5).listType);
                            v1_2.put("impression", ((com.ss.android.model.b) v0_5).jsonArray);
                            if (!android.support.design.a.isTextEmpty(arg14)) {
                                v1_2.put("session_id", arg14);
                            }

                            if (android.support.design.a.isTextEmpty(((com.ss.android.model.b) v0_5).extra)) {
//                            goto label_94;
                            } else {
                                v1_2.put("extra", new JSONObject(((com.ss.android.model.b) v0_5).extra));
                            }
                        }

                        label_94:
                        v3.put(v1_2);
                        continue;
                    } catch (Exception v0_2) {
                        label_103:
                        Logger.w("ImpressionHelper", "batch impression exception: " + v0_2);
                    }
                }
                v1_1 = 0;

            }

            if (v3.length() <= 0) {
                return;
            }

            try {
                arg15.put("item_impression", v3);
            } catch (JSONException v0_6) {
            }
        }
    }

    public void a(Context arg2) {
        super.a(arg2);
        BaseImageManager.a = this.c;
        System.currentTimeMillis();
    }

    public void a(SharedPreferences.Editor editor) {
        super.a(editor);
        editor.putString("report_options", this.ct);
        editor.putString("report_user_options", this.cu);
        editor.putString("report_video_options", this.cv);
        editor.putString("report_comment_options", this.i);
        editor.putInt("update_sdk", this.cw);
        editor.putInt("use_sys_notification_style", this.cx);
        editor.putBoolean("key_regist_device_manager_showed", this.a);
        editor.putInt("appsee_enable", this.ck);
        editor.putInt("ssl_error_handle", this.cy);
    }

    public void a(SharedPreferences sp) {
        super.a(sp);
        this.ct = sp.getString("report_options", null);
        this.cu = sp.getString("report_user_options", null);
        this.cv = sp.getString("report_video_options", null);
        this.i = sp.getString("report_comment_options", null);
        this.cw = sp.getInt("update_sdk", -1);
        this.cx = sp.getInt("use_sys_notification_style", 0);
        this.a = sp.getBoolean("key_regist_device_manager_showed", false);
        this.ck = sp.getInt("appsee_enable", 0);
        this.cy = sp.getInt("ssl_error_handle", 0);
    }

    public void a(String arg1, boolean arg2) {
    }

    public void onAppBackgroundSwitch(boolean arg1) {
    }

    public final boolean onActivityResult(Activity activity, int arg3, int arg4, Intent intent) {
        return arg3 == 32973 || super.onActivityResult(activity, arg3, arg4, intent);
    }

    public boolean a(JSONObject jo) {
        int v0;
        List v8 = null;
        int v7 = -1;
        boolean v2 = false;
        boolean v3 = super.a(jo);
        boolean[] v4 = new boolean[1];
        jo.optInt("load_thirdparty_lib", v7);
        this.ct = a(v4, jo, "report_options", this.ct);
        if (v4[0]) {
            this.bY = v8;
            v0 = 1;
        } else {
            v0 = 0;
        }

        this.cu = a(v4, jo, "report_user_options", this.cu);
        if (v4[0]) {
            this.bZ = v8;
            v0 = 1;
        }

        this.cv = a(v4, jo, "report_video_options", this.cv);
        if (v4[0]) {
            this.ca = v8;
            v0 = 1;
        }

        this.i = a(v4, jo, "report_comment_options", this.i);
        if (v4[0]) {
            v0 = 1;
        }

        int v4_1 = jo.optInt("update_sdk", 1);
        if (v4_1 != this.cw) {
            this.cw = v4_1;
            v0 = 1;
        }

        v4_1 = jo.optInt("use_sys_notification_style", v7);
        if (v4_1 >= 0 && v4_1 != this.cx) {
            this.cx = v4_1;
            v0 = 1;
        }

        v4_1 = jo.optInt("appsee_enable", v7);
        if (v4_1 >= 0 && v4_1 != this.ck) {
            this.ck = v4_1;
            v0 = 1;
        }

        v4_1 = jo.optInt("ssl_error_handle", 0);
        if (v4_1 >= 0 && v4_1 != this.cy) {
            this.cy = v4_1;
            v0 = 1;
        }

        if ((v3) || v0 != 0) {
            v2 = true;
        }

        return v2;
    }

    public static BaseAppData inst() {
        if (BaseAppData.instance == null) {
            MediaAppDataProvider v0 = ComponentsManifest.findComponent(MediaAppDataProvider.class);
            if (v0 == null) {
                throw new IllegalStateException("BaseAppData not init");
            } else {
                BaseAppData.instance = v0.provide();
            }
        }

        return (BaseAppData) BaseAppData.instance;
    }

    public final String aC() {
        StringBuilder v1 = new StringBuilder();
        v1.append("v");
        String v0 = this.appContext.getAppVersion();
        if (v0 == null) {
            v0 = "1.0";
        }

        v1.append(v0);
        v1.append(" Build ").append(this.appContext.getChannel()).append("_");
        v1.append(TtProperties.getInstance(this.mContext).getString("release_build", ""));
        return v1.toString();
    }

    public final boolean aD() {
        try {
            String v0_1 = this.getAppContext().getChannel();
            if (!"local_test".equals(v0_1) && !"local_dev".equals(v0_1)) {
                return false;
            }

            return true;
        } catch (Exception v0) {
        }
        return false;
    }

    public final void aE() {
        this.cR.add("night_mode");
        com.ss.android.j.b.a();
        this.cL = true;
    }

    public final long aF() {
        return this.d.get() + BaseAppData.ce.get();
    }

    public final void aG() {
        this.d();
        this.mWeakHandler.postDelayed(new com.ss.android.newmedia.gg(this), ((long) (UpdateHelper.getInstance().p() * 1000)));
    }

    public final UpdateChecker getUpdateChecker() {
        if (this.cw == -1 || this.cw == 0) {
            return UpdateChecker.a;
        } else {
            if (this.cw == 2) {
                try {
                    return (UpdateChecker) Class.forName("com.ss.android.common.update.MMUpdateChecker").newInstance();
                } catch (Throwable throwable) {
                    throwable.printStackTrace();
                }
            }
            return new SSUpdateChecker();
        }
    }

    public final void aI() {
        if (this.mUnifyApiUserAgent != 0) {
            NetworkUtils.setUserAgent(this.userAgent());
        } else {
            NetworkUtils.setUserAgent((String) null);
        }
    }

    public final Class getBrowserActivityClass() {
        return BrowserActivity.class;
    }

    public static void aK() {
    }

    public static boolean isInitialized() {
        return instance != null;
    }

    public boolean shouldShow() {
        return false;
    }

    public Class ab() {
        return null;
    }

    public String ae() {
        return null;
    }

    public Class af() {
        return null;
    }

    static AtomicLong b(BaseAppData arg1) {
        return arg1.d;
    }

    public void b(long arg1) {
    }

    static Runnable c(BaseAppData arg1) {
        return arg1.f;
    }

    public final void setSessionId(long sessionId) {
        this.mWeakHandler.sendEmptyMessage(103);
        ImpressionHelper.getInstance().sessionId.set(sessionId);
        this.sessionId = sessionId;
    }

    public boolean c(String arg2) {
        return false;
    }

    public final void c_() {
    }

    public JsObject createJsObject(Context arg2) {
        return new JsObject(this, arg2);
    }

    public final void onActivityPaused(Activity activity) {
        super.onActivityPaused(activity);
        this.mAlertManager.b();
    }

    public final String e() {
        return SpipeCore.getAppId();
    }

    public final boolean e(Activity arg2) {
        return !(arg2 instanceof AbsSplashActivity) || (((AbsSplashActivity) arg2).i);
    }

    public String f(String arg1) {
        return arg1;
    }

    public final void f(Activity activity) {
        super.f(activity);
        this.mAlertManager.b();
    }

    public final void f(Context arg13) {
        String v0_2;
        SharePlatform v6_1;
        SharePlatform[] v1_3;
        int v5_3;
        super.f(arg13);
        Spipe v2 = Spipe.inst();
        if (v2.N) {
            AdManager.getInstance(arg13).a();
            return;
        }

        v2.N = true;
        SharedPreferences v3 = arg13.getSharedPreferences("com.ss.spipe_setting", 0);
        v2.isLogin = v3.getBoolean("is_login", false);
        v2.userId = v3.getLong("user_id", 0);
        v2.sessionKey = v3.getString("session_key", "");
        v2.userName = v3.getString("user_name", "");
        v2.userGender = v3.getInt("user_gender", 0);
        v2.screenName = v3.getString("screen_name", "");
        v2.userVerified = v3.getBoolean("user_verified", false);
        v2.avatarUrl = v3.getString("avatar_url", "");
        v2.userDescription = v3.getString("user_description", "");
        v2.userBirthday = v3.getString("user_birthday", "");
        v2.userLocation = v3.getString("user_location", "");
        v2.userScore = v3.getInt("user_score", 0);
        v2.isRecommendAllowed = v3.getBoolean("is_recommend_allowed", false);
        v2.recommendHintMessage = v3.getString("recommend_hint_message", "");
        v2.lastShowWeiboExpiredTime = v3.getLong("last_show_weibo_expired_time", 0);
        v2.mediaId = v3.getLong("media_id", 0);
        v2.verifyStatus = v3.getBoolean("verify_status", false);
        if ((v2.isLogin) && v2.userId <= 0) {
            v2.isLogin = false;
            v2.userId = 0;
        } else if (!v2.isLogin && v2.userId > 0) {
            v2.userId = 0;
        }

        ++v2.z;
        try {
            HashMap v4 = new HashMap();
            String v5 = v3.getString("platforms", null);
            String v6 = v3.getString("publish_selected_platforms", null);
            String v1 = v3.getString("expire_platforms", null);
            JSONObject v1_1 = android.support.design.a.isTextEmpty(v1) ? new JSONObject() : new JSONObject(v1);
            if (!android.support.design.a.isTextEmpty(v5)) {
                String[] v5_1 = v5.split(",");
                if (v5_1 != null && v5_1.length > 0) {
                    int v7 = v5_1.length;
                    int v0_1;
                    for (v0_1 = 0; v0_1 < v7; ++v0_1) {
                        v4.put(v5_1[v0_1], v5_1[v0_1]);
                    }

                    SharePlatform[] v5_2 = v2.mSharePlatforms;
                    v7 = v5_2.length;
                    for (v0_1 = 0; v0_1 < v7; ++v0_1) {
                        SharePlatform v8 = v5_2[v0_1];
                        if (v4.containsKey(v8.mName)) {
                            v8.mSelected = true;
                        }

                        if (!v1_1.isNull(v8.mName)) {
                            v8.mNotTipExpiredTime = v1_1.optLong(v8.mName, -1);
                        }
                    }
                }
            }

            v4.clear();
            if (android.support.design.a.isTextEmpty(v6)) {
//                goto label_185;
            } else {
                String[] v1_2 = v6.split(",");
                if (v1_2 == null) {
//                goto label_185;
                } else if (v1_2.length <= 0) {
//                goto label_185;
                } else {
                    int v0_1 = 0;
                    v5_3 = v1_2.length;
                    for (v0_1 = 0; v0_1 < v5_3; ++v0_1) {
                        v4.put(v1_2[v0_1], v1_2[v0_1]);
                    }

                    v1_3 = v2.mSharePlatforms;
                    v5_3 = v1_3.length;
                    v0_1 = 0;
                    while (true) {
                        label_168:
                        if (v0_1 >= v5_3) {
                            break;
                        }
                        v6_1 = v1_3[v0_1];
                        if (v4.containsKey(v6_1.mName)) {
                            v6_1.mPublishSelected = true;
                        }
                        ++v0_1;
                        continue;
                    }
                }
            }
        } catch (Exception v0) {
            Logger.d("snssdk", "load selection exception: " + v0);
        }

        try {
//            label_185:
            HashMap v1_4 = new HashMap();
            v0_2 = v3.getString("showed_platforms", null);
            if (android.support.design.a.isTextEmpty(v0_2)) {
//                goto label_225;
            } else {
                String[] v4_1 = v0_2.split(",");
                if (v4_1 == null) {
//                goto label_225;
                } else if (v4_1.length <= 0) {
//                goto label_225;
                } else {
                    v5_3 = v4_1.length;
                    int v0_1 = 0;
                    for (v0_1 = 0; v0_1 < v5_3; ++v0_1) {
                        v1_4.put(v4_1[v0_1], null);
                    }
                    SharePlatform[] v4_2 = v2.mSharePlatforms;
                    v5_3 = v4_2.length;
                    v0_1 = 0;
                    while (true) {
                        label_208:
                        if (v0_1 >= v5_3) {
                            break;
                        }
                        v6_1 = v4_2[v0_1];
                        if (v1_4.containsKey(v6_1.mName)) {
                            v6_1.mRecommendShowed = true;
                        }

                        ++v0_1;
                        continue;
                    }
                }
            }
        } catch (Exception v0) {
            Logger.d("snssdk", "load showed platform exception: " + v0);
        }

        v1_3 = v2.M;
        for (int v0_1 = 0; v0_1 < 3; ++v0_1) {
            v1_3[v0_1].mLogin = false;
        }

        v0_2 = v3.getString("session", null);
        Logger.d("snssdk", "loadSession: " + v0_2);
        if (!android.support.design.a.isTextEmpty(v0_2)) {
            CookieManager v1_5 = CookieManager.getInstance();
            SimpleDateFormat v4_3 = new SimpleDateFormat("EEE, dd-MMM-yyyy HH:mm:ss \'GMT\'", Locale.US);
            v4_3.setTimeZone(TimeZone.getTimeZone("GMT"));
            Date v5_4 = new Date(System.currentTimeMillis() + 2592000000L);
            StringBuilder v6_2 = new StringBuilder();
            v6_2.append("sessionid=").append(v0_2);
            v6_2.append("; Domain=.snssdk.com");
            v6_2.append("; expires=").append(v4_3.format(v5_4));
            v6_2.append("; Max-Age=2591999");
            v6_2.append("; Path=/");
            v1_5.setCookie("http://i.snssdk.com/", v6_2.toString());
            SharedPreferences.Editor v0_3 = v3.edit();
            v0_3.remove("session");
            SharedPreferenceCompat.commit(v0_3);
        }

        if (v2.userId > 0) {
            AppLog.a(v2.userId);
            AppLog.d(v2.sessionKey);
        }

        label_288:
        AdManager.getInstance(arg13).a();
    }

    public final void g(Context arg2) {
        super.g(arg2);
        Spipe.inst().c(arg2);
    }

    public static synchronized boolean h(Context arg4) {
        boolean v0 = true;
        try {
            if (mConfirmPush == -1) {
                mConfirmPush = 1;
            }

            if (mConfirmPush <= 0) {
                v0 = false;
            }

            v0 = Boolean.valueOf(v0).booleanValue();
        } catch (Exception v0_1) {
            v0 = Boolean.TRUE.booleanValue();
        }
        return v0;
    }

    public void handleMsg(Message message) {
        super.handleMsg(message);
    }

    public static synchronized boolean i(Context arg4) {
        boolean v0 = true;
        try {
            if (h == -1) {
                h = 1;
            }

            if (h <= 0) {
                v0 = false;
            }

            label_10:
            v0 = Boolean.valueOf(v0).booleanValue();
        } catch (Exception v0_1) {
            v0 = Boolean.TRUE.booleanValue();
        }
        return v0;
    }

    final void j(Context arg13) {
        int v9 = 16;
        long v10 = 1000;
        if (!this.e) {
            UpdateHelper v0 = UpdateHelper.getInstance();
            if (v0.h()) {
                long v2 = System.currentTimeMillis();
                int v1 = v0.d();
                if (v0.j()) {
                    if (v1 != this.predownloadVersion) {
                        this.predownloadVersion = v1;
                        this.preDownloadDelayDays = v0.k();
                        this.preDownloadDelaySecond = v0.l();
                        this.preDownloadStartTime = v2;
                        SharedPreferences.Editor v4 = arg13.getSharedPreferences("app_setting", 0).edit();
                        v4.putInt("pre_download_version", this.predownloadVersion);
                        v4.putInt("pre_download_delay_days", this.preDownloadDelayDays);
                        v4.putLong("pre_download_delay_second", this.preDownloadDelaySecond);
                        v4.putLong("pre_download_start_time", this.preDownloadStartTime);
                        SharedPreferenceCompat.commit(v4);
                    }

                    if (Logger.debug()) {
                        Logger.i("UpdateHelper", "need pre download, version " + this.predownloadVersion
                                + ", delay " + this.preDownloadDelayDays
                                + ", delay s " + this.preDownloadDelaySecond
                                + ", start " + this.preDownloadStartTime);
                    }

                    if (v0.r() != null) {
//                        goto label_69;
                    } else if (!NetworkUtils.isWifi(arg13)) {
//                        goto label_69;
                    } else {
                        v0.u();
                        if (!Logger.debug()) {
//                        goto label_69;
                        } else {
                            Logger.i("UpdateHelper", "begin pre download");
                        }
                    }
                }

                label_69:
                if (this.preDownloadDelaySecond != -1) {
                    if ((v0.j()) && v2 - this.preDownloadStartTime < this.preDownloadDelaySecond * v10) {
                        if (Logger.debug()) {
                            Logger.i("UpdateHelper", "in ore download delay second");
                        } else {
                        }

                        return;
                    }
                } else if ((v0.j()) && v2 - this.preDownloadStartTime < (((long) (this.preDownloadDelayDays * 24 * 3600))) * v10) {
                    if (Logger.debug()) {
                        Logger.i("UpdateHelper", "in pre download delay");
                    } else {
                    }

                    return;
                }

                if (Logger.debug()) {
                    Logger.i("UpdateHelper", "hint version " + this.lastHintVersioni
                            + ", delay " + this.hintVersionDelayDays
                            + ", start " + this.lastHintTime);
                }

                if (v1 != this.lastHintVersioni) {
                    this.hintVersionDelayDays = 0;
                    this.lastHintTime = 0;
                }

                if (v2 - this.lastHintTime < (((long) (this.hintVersionDelayDays * 24 * 3600))) * v10) {
                    return;
                }

                if (!NetworkUtils.isWifi(arg13) && !v0.m()) {
                    return;
                }

                if (this.hintVersionDelayDays <= 0) {
                    this.hintVersionDelayDays = 1;
                } else {
                    this.hintVersionDelayDays <<= 1;
                    if (this.hintVersionDelayDays > v9) {
                        this.hintVersionDelayDays = v9;
                    }
                }

                this.lastHintVersioni = v1;
                this.lastHintTime = v2;
                SharedPreferences.Editor v1_1 = arg13.getSharedPreferences("app_setting", 0).edit();
                v1_1.putInt("last_hint_version", this.lastHintVersioni);
                v1_1.putInt("hint_version_delay_days", this.hintVersionDelayDays);
                v1_1.putLong("last_hint_time", this.lastHintTime);
                SharedPreferenceCompat.commit(v1_1);
                v0.a(arg13);
            }
        }
    }

    public final void k(Context context) {
        long v10 = 1000;
        this.e = false;
        UpdateHelper v0 = UpdateHelper.getInstance();
        if (v0.h()) {
            long currentTimeMillis = System.currentTimeMillis();
            int v1 = v0.d();
            if (v0.j()) {
                if (v1 != this.predownloadVersion) {
                    this.predownloadVersion = v1;
                    this.preDownloadDelayDays = v0.k();
                    this.preDownloadDelaySecond = v0.l();
                    this.preDownloadStartTime = currentTimeMillis;
                    SharedPreferences.Editor editor = context.getSharedPreferences("app_setting", 0).edit();
                    editor.putInt("pre_download_version", this.predownloadVersion);
                    editor.putInt("pre_download_delay_days", this.preDownloadDelayDays);
                    editor.putLong("pre_download_delay_second", this.preDownloadDelaySecond);
                    editor.putLong("pre_download_start_time", this.preDownloadStartTime);
                    SharedPreferenceCompat.commit(editor);
                }

                if (v0.r() != null) {
//                    goto label_40;
                } else if (!NetworkUtils.isWifi(context)) {
//                    goto label_40;
                } else {
                    v0.u();
                }
            }

            label_40:
            if (this.preDownloadDelaySecond != -1) {
                if ((v0.j()) && currentTimeMillis - this.preDownloadStartTime < this.preDownloadDelaySecond * v10) {
                    return;
                }
            } else if ((v0.j()) && currentTimeMillis - this.preDownloadStartTime < (((long) (this.preDownloadDelayDays * 24 * 3600))) * v10) {
                return;
            }

            if (!v0.m()) {
                return;
            }

            this.lastHintVersioni = v1;
            this.lastHintTime = currentTimeMillis;
            SharedPreferences.Editor v1_1 = context.getSharedPreferences("app_setting", 0).edit();
            v1_1.putInt("last_hint_version", this.lastHintVersioni);
            v1_1.putLong("last_hint_time", this.lastHintTime);
            SharedPreferenceCompat.commit(v1_1);
            v0.a(context);
            this.e = true;
        }
    }

    public final IWXAPI l(Context arg3) {
        IWXAPI v0 = null;
        if (!android.support.design.a.isTextEmpty(this.cc)) {
            v0 = WXAPIFactory.createWXAPI(arg3, this.cc, true);
        }

        return v0;
    }

    public void onAccountRefresh(boolean arg1, int arg2) {
    }

    public String r() {
        return null;
    }

    public abstract boolean isAppForeground();
}

